<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>订单管理</title>
<%@include file="/common/head.jsp" %>
<link href="<%=request.getContextPath()%>/static/plugin/zTree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet">
<script src="<%=request.getContextPath()%>/static/plugin/zTree/js/jquery.ztree.all-3.5.min.js"></script>
<style>
    #content {
        position: absolute;
        top: 0;
        left: 240px;
        right: 10px;
        bottom: 0;
        box-sizing: border-box;
    }
    ul.ztree {
       width: 230px;
    }
</style>
</head>
<body class="iframe-page">
  <div class="tree-wrap" id="orgTree">
  </div>
    
    <div id="content">
        <iframe id="userFrame" frameborder="0" style="width: 100%;height: 100%" src="<%=request.getContextPath()%>/user/order/initOrder"></iframe>
    </div>
<script>
	var userFrame = document.getElementById("userFrame");
	
    $(function () {
		//初始化左侧用户树
		initOrgTree('userTree', USER_CONST_URL.GET_TREE);
    });
    
    //初始化组织机构树
    function initOrgTree(treeId, urlv) {
            //'id', 'realname'
             // alert(00000);
            //return;
                  var imgparams={
                      openId : ""
                      } 
            
                   $.ajax({
                   	type : "GET",
                   	url : urlv,
                   	dataType : 'json',
                   	async: false,
                   	contentType : "application/json",
                   	data : imgparams,
                   	success : function(ro) {
                   		var treestr = "";
                   		//alert(ro.result);
                   		//return;
                   		if(ro.result == "success"){
                   			
                     	    //alert("成功");
                     	    $.each(ro.data, function(index, vo){
                     	    	treestr = treestr + "<div class='tree-title' num="+vo.id+">"+vo.realname+"</div>";
                     	    });
                            
                           $("#orgTree").append(treestr);
                           
                           //加载事件
                   	    $.each($('.tree-title'),function (index,item) {
                 	       $(item).on('click',function (e) {
                 	    	  var uid = $(this).attr("num");
                 	    	   //alert(uid);
                 	    	   //return;
                 	    	  selectOrdersByOrgCode(uid);
                 	       })
                 	    });
                           
                   		}

                   	},
                   	error : function(err) {
                   		  alert(err.message);
                   	}
                   });
    }
    
    //点击组织机构树查询用户
    function selectOrdersByOrgCode(userId) {
  	   //alert(userId);
  	   //return;
        url = USER_CONST_URL.INIT_USER + "?uid=" + userId;
        userFrame.src = url; 
    }
   
   
    //请求url
    var USER_CONST_URL = {
       	GET_TREE: basePath + "/user/htuser/list",
       	INIT_USER: basePath + '/user/order/initOrder'
    };
    
</script>
</body>
</html>